<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model_admin extends CI_Model {

	public function __construct() 
	{
		parent::__construct();
		
		$this->load->helper(array('form','captcha','array'));
		$this->load->library(array('form_validation','session','table','sam','tank_auth','upload'));
		$this->load->database();
		//$this->model_auth->_must_logged_in('jpc');
	}
	
	public function __reset_password ($usertype, $usertype_id){
	
		$query = $this->db->get_where('users', 
				array (
					'usertype'=>$usertype,
					'usertype_id'=>$usertype_id,
				));
		$new_pass = $this->sam->_random_string(10);
		// print_r($query->row()->id);
		$this->tank_auth->reset_password($query->row()->id, $new_pass);		
		
		return $new_pass;
				
	}
	
	
	public function _edit_spc ($data, $usertype_id) {
		$select= array(	'spc_nama_tim',
						'spc_nama_pt',
						'spc_alamat_pt',
						'spc_nama_1',
						'spc_nohp',
						'spc_email',
						'spc_nama_2',
						'spc_nama_3',
						'spc_pembimbing',
						'spc_valid',
						'spc_kaos_1',
						'spc_kaos_2',
						'spc_kaos_3',
						'spc_finalis'
						);
		$data= elements($select, $data);
		$this->db->where('spc_no_tim', $usertype_id);
		$this->db->update('spc', $data); 	
	}
	
	public function _edit_jpc ($data, $usertype_id) {
		$select= array(	
						'jpc_nama_sek',
						'jpc_alamat_sek',
						'jpc_nama',
						'jpc_kelas',
						'jpc_nohp',
						'jpc_email',
						'jpc_pembimbing',
						'jpc_valid',
						'jpc_kaos',
						'jpc_finalis'
						);
		$data= elements($select, $data);
		$this->db->where('jpc_no_tim', $usertype_id);
		$this->db->update('jpc', $data); 	
	}
	
	

	
}